﻿// Decompiled with JetBrains decompiler
// Type: MCM.LightInject.ServiceNameProvider
// Assembly: MCMv5, Version=5.10.2.0, Culture=neutral, PublicKeyToken=null
// MVID: 7AB326B9-B2B4-41C2-9177-68E944071101
// Assembly location: D:\steam\steamapps\workshop\content\261550\2859238197\bin\Win64_Shipping_Client\MCMv5.dll

using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Reflection;
using System.Text.RegularExpressions;

#nullable disable
namespace MCM.LightInject
{
  [ExcludeFromCodeCoverage]
  internal class ServiceNameProvider : IServiceNameProvider
  {
    public string GetServiceName(Type serviceType, Type implementingType)
    {
      string input = implementingType.FullName;
      string fullName = serviceType.FullName;
      if (implementingType.GetTypeInfo().IsGenericTypeDefinition)
      {
        Regex regex = new Regex("((?:[a-z][a-z.]+))", RegexOptions.IgnoreCase);
        input = regex.Match(input).Groups[1].Value;
        fullName = regex.Match(fullName).Groups[1].Value;
      }
      if (((IEnumerable<string>) fullName.Split('.')).Last<string>().Substring(1) == ((IEnumerable<string>) input.Split('.')).Last<string>())
        input = string.Empty;
      return input;
    }
  }
}
